package com.ruoyi.blog.controller.api;

import com.ruoyi.blog.domain.BlogLinkApply;
import com.ruoyi.blog.service.IBlogLinkApplyService;
import com.ruoyi.blog.service.IBlogLinksService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/api/blog/link")
public class LinkController extends BaseController {

    @Autowired
    private IBlogLinksService iBlogLinksService;

    @Autowired
    private IBlogLinkApplyService iBlogLinkApplyService;

    /**
     * 查询友情链接列表数据
     * @return
     */
    @GetMapping("getLinkList")
    public AjaxResult getLinkList() {
        return AjaxResult.success(iBlogLinksService.selectBlogLinksList(null) );
    }

    /**
     * 提交友情链接申请
     * @param apply
     * @return
     */
    @PostMapping("linkApply")
    public AjaxResult linkApply(@RequestBody BlogLinkApply apply) {
        apply.setCreateTime(new Date());
        apply.setStatus("0");
        iBlogLinkApplyService.insertBlogLinkApply(apply);
        return AjaxResult.success();
    }

}